document.addEventListener('DOMContentLoaded', function() {
    LoadAttendanceData();
});
function LoadAttendanceData(){
    $.ajax(
        {
            url:`http://localhost:9220/AttendanceSystem/AttendanceRecordController`,
            method:"post",
            dataType:"json",
            success:function (data) {
                // console.log(data)
                renderAttendanceTable(data);
            },
            error:function (error,xhr,status) {
                console.error("请求失败详情:", {
                    "状态码": xhr.status,
                    "状态": status,
                    "响应内容": xhr.responseText
                });
            }
        }
    )
}
function renderAttendanceTable(data){
    const $tbody = $(".attendance-table tbody");
    $tbody.empty();
    $.each(data,function (index,item) {
        // console.log(item.status)


        const row = `            
            <tr>
                <td>${item.attendance_date}</td>
                <td>${item.course_name}</td>
                <td><span class="status present">${item.status}</span></td>
            </tr>
        `;
        $tbody.append(row);
})
}